{% extends "layout.html" %}

{% block title %}
    {{ searched_ident|e }} identifier - {{ current_project|capitalize }} source code {{ current_tag }} - Bootlin Elixir Cross Referencer
{% endblock %}

{% block description -%}
    Elixir Cross Referencer - {{ searched_ident|e }} identifier references search for {{ current_project|capitalize }} {{ current_tag }}.
    {%- for section in symbol_sections -%}
        {%- if 'symbols' in section -%}
            {%- for type, symbols in (section['symbols'].items()) -%}
                {%- if (symbols|length) == 1 %}
                    {{ section['title'] }} {{- ' as a '+type if type != '_unknown' else '' }} in {{ symbols[0].path }}.
                {%- else %}
                    {{ section['title'] }} in {{ symbols|length }} files {{- ' as a '+type if type != '_unknown' else '' -}}: {{ symbols[0].path }}...
                {%- endif %}
            {%- endfor -%}
        {%- endif -%}
    {%- endfor -%}
{%- endblock -%}

{% block main %}

<div class="lxrident">
{% if symbol_sections|length != 0 %}
    {% for section in symbol_sections %}
        {% if 'symbols' in section %}
            {% for type, symbols in section['symbols'].items() %}
                <h2>{{ section['title'] }} in {{ symbols|length }} files
                    {{- ' as a '+type if type != '_unknown' else '' -}}:</h2>
                <ul>
                {% for symbol in symbols %}
                    <li>
                    <a href="{{ symbol.lines[0].url }}">
                        <strong>{{ symbol.path }}</strong>
                        {%- if symbol.lines|length == 1 %},
                            line {{ symbol.lines[0].lineno }}
                        {%- elif symbols|length > 100 %},
                            <em>{{ symbol.lines|length }} times</em>
                        {% endif %}
                        {% if symbol.type is not none %}
                            <em>(as a {{ symbol.type }})</em>
                        {% endif %}
                    </a>
                    {% if symbol.lines|length > 1 and symbols|length <= 100 %}
                        <ul>
                        {% for line, url in symbol.lines %}
                            <li><a href="{{ url }}">line {{ line }}</a>
                        {% endfor %}
                        </ul>
                    {% endif %}
                {% endfor %}
                </ul>
            {% endfor %}
        {% else %}
            <h2>{{ section['message'] }}</h2>
        {% endif %}
    {% endfor %}
{% else %}
    <h2>Identifier not used</h2>
{% endif %}
</div>

{% endblock %}
